package com.alifi.crm.dal;

import java.util.Date;

public abstract class BaseDO {
	
	private Long id;
	
	/**
     * 创建时间
     */
    private Date gmtCreated;
    /**
     * 修改时间
     */
    private Date gmtModified;
	
    /**
     * 创建者
     */
    private String creator;
    /**
     * 修改者
     */
    private String modifier;
    
    
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public Date getGmtCreated() {
		return gmtCreated;
	}
	public void setGmtCreated(Date gmtCreated) {
		this.gmtCreated = gmtCreated;
	}
	public Date getGmtModified() {
		return gmtModified;
	}
	public void setGmtModified(Date gmtModified) {
		this.gmtModified = gmtModified;
	}
	public String getCreator() {
		return creator;
	}
	public void setCreator(String creator) {
		this.creator = creator;
	}
	public String getModifier() {
		return modifier;
	}
	public void setModifier(String modifier) {
		this.modifier = modifier;
	}
    

	@Override
	public int hashCode() {
		Long id = getId();
		if (id == null) {
			return super.hashCode();
		}
		return id.hashCode() * 19;
	}

	/**
	 * 鐩稿悓绫诲瀷锛屽苟涓擨D鐩哥瓑鐨勫璞″氨鐩哥瓑
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		Long id = getId();
		if (obj instanceof BaseDO && id != null
				&& getClass().isInstance(obj)) {
			// 鑰冭檻鍒拌姣旇緝鐨勭被鍨嬫湁鍙兘琚唬鐞嗙敓鎴愪簡瀛愮被
			@SuppressWarnings("unchecked")
			BaseDO target = (BaseDO) obj;
			return id.equals(target.getId());
		}
		return super.equals(obj);
	}

	@Override
	public String toString() {
		Long id = getId();
		if (id == null) {
			return super.toString();
		}
		return getClass().getName() + "@id=" + id;
	}
    
    
}
